function changeUserLang(lang) {
    var isValid = false;

    $.ajax({
        type: "POST",
        url: '/users/language',
        data: { lang: lang },
        async: false,
        success: function(data) { isValid = data; }
    });

    if (!isValid) {
        $.status.showError(Resources.T("There was an error changing your language. Please try again later."));
        return false;
    }
};

var langPopup = null;

function showLangPopup() {
    langPopup = jQuery.floatbox({
        ajax: {
            url: '/users/language',
            before: '<br/><p class="loading">' + "Loading..." + "</p>",
            params: ""
        },
        boxConfig: { width: '350px', marginLeft: '-175px' },
        fade: true,
        button: ""
    });
}

function closeLangPopup() {
    if (langPopup) {
        langPopup.closeBox();
        langPopup = null;
    }
}